﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MpSoft.Library.BUSS.Settings; 

namespace MpSoft.Web.AdminCP.Controls.Configs
{
    public partial class SetSeo : System.Web.UI.UserControl
    {
        #region Method

        private void BindControl()
        {
            txtMetaTitle.Text = SettingBUSS.GetSettingValue("seo.Title");
            txtMetaKeyWord.Text = SettingBUSS.GetSettingValue("seo.Keyword");
            txtMetaDescription.Text = SettingBUSS.GetSettingValue("seo.description");
        }

        public int Save()
        {
            var seo = SettingBUSS.Setting_ByKey("seo.Title");
            // title
            seo.SettingValue = txtMetaTitle.Text;
            seo.SettingGroup = "seo";
            SettingBUSS.Setting_Update(seo);
            //Keyword 
            seo = SettingBUSS.Setting_ByKey("seo.Keyword");
            seo.SettingValue = txtMetaKeyWord.Text;
            seo.SettingGroup = "seo";
            SettingBUSS.Setting_Update(seo);
            //description
            seo = SettingBUSS.Setting_ByKey("seo.description");
            seo.SettingValue = txtMetaDescription.Text;
            seo.SettingGroup = "seo";
            SettingBUSS.Setting_Update(seo);
            return 1;
        }

        #endregion

        #region Event

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                BindControl();
        }

        #endregion
    }
}